package com.bristua.tencent.rtc.sdk.push.business.dao.impl;

import android.support.annotation.NonNull;
import android.text.TextUtils;

import com.alibaba.fastjson.JSON;
import com.bristua.tencent.rtc.sdk.provider.RtcContainer;
import com.bristua.tencent.rtc.sdk.push.business.api.IRtcPushApi;
import com.bristua.tencent.rtc.sdk.push.business.dao.IGetPushUrlDao;
import com.hua.yuan.common.https.OkHttpModule;

import java.util.HashMap;
import java.util.Map;

import okhttp3.RequestBody;
import retrofit2.Call;

import static com.bristua.tencent.rtc.sdk.push.IRtcPushBusiness.MEDIA_JSON;

/**
 * @Author: richsjeson.
 * @Description: TODO()
 * @Date:Created in 2019/1/20 11:40 PM.
 * @Modified By:
 */
public class GetPushUrlDaoImpl implements IGetPushUrlDao {
    @Override
    public String getPushUrl(@NonNull final String pRoomId, @NonNull final String pUserId) {
        Map postParams =new HashMap<>();
        postParams.put(RtcContainer.RTC_USER_ID,pUserId);
        if(!TextUtils.isEmpty(pRoomId)){
            postParams.put(RtcContainer.RTC_ROOM_ID,pRoomId);
        }
        String json=JSON.toJSONString(postParams);
        RequestBody responseBody=RequestBody.create(MEDIA_JSON,json);
        IRtcPushApi rtcPushApi= OkHttpModule.getInstance().getRetrofit().create(IRtcPushApi.class);
        Call<String> call=rtcPushApi.pusher(String.format("%s/%s",RtcContainer.RTC_SERVER_ROOM,"get_push_url"),pUserId,RtcContainer.STORAGE_RTC_TOKEN,responseBody);
        return null;
    }
}
